package com.kgc.controller;

import com.kgc.basic.pojo.GoodsCategory;
import com.kgc.basic.pojo.Store;
import com.kgc.basic.util.ResponseMsg;
import com.kgc.feign.GoodsCategoryFeign;
import com.kgc.feign.StoreFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/goodsCategory")
public class GoodsCategoryController {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private GoodsCategoryFeign goodsCategoryFeign;

    @RequestMapping("getGoodsCategoryList")
    public ResponseMsg getGoodsCategoryList(@RequestBody Map<String, Object> paramMap) {
        logger.info("GoodsCategoryController getGoodsCategoryList paramMap:"+paramMap);
        ResponseMsg msg = goodsCategoryFeign.getGoodsCategoryList(paramMap);
        logger.debug("GoodsCategoryController getGoodsCategoryList msg:"+msg);
        return msg;
    }



    @RequestMapping("getGoodsCategoryById")
    public ResponseMsg getGoodsCategoryById(@RequestParam("id") Integer id) {
        logger.info("GoodsCategoryController getGoodsCategoryById id:"+id);
        ResponseMsg msg = goodsCategoryFeign.getGoodsCategoryById(id);
        logger.debug("GoodsCategoryController getGoodsCategoryById msg:"+msg);
        return msg;
    }

    @RequestMapping("addGoodsCategory")
    public ResponseMsg addGoodsCategory(@RequestBody GoodsCategory goodsCategory) {
        logger.info("GoodsCategoryController addGoodsCategory goodsCategory:"+goodsCategory);
        ResponseMsg msg = goodsCategoryFeign.addGoodsCategory(goodsCategory);
        logger.debug("GoodsCategoryController addGoodsCategory msg:"+msg);
        return msg;
    }

    @RequestMapping("modifyGoodsCategory")
    public ResponseMsg modifyGoodsCategory(@RequestBody GoodsCategory goodsCategory) {
        logger.info("GoodsCategoryController modifyGoodsCategory goodsCategory:"+goodsCategory);
        ResponseMsg msg = goodsCategoryFeign.modifyGoodsCategory(goodsCategory);
        logger.debug("GoodsCategoryController modifyGoodsCategory msg:"+msg);
        return msg;
    }

    @RequestMapping("delGoodsCategory")
    public ResponseMsg delGoodsCategory(@RequestParam("id") Integer id) {
        logger.info("GoodsCategoryController delGoodsCategory id:"+id);
        ResponseMsg msg = goodsCategoryFeign.delGoodsCategory(id);
        logger.debug("GoodsCategoryController delGoodsCategory msg:"+msg);
        return msg;
    }

    @RequestMapping("showGoodsCategoryByTree")
    public ResponseMsg showGoodsCategoryByTree() {
        logger.info("GoodsCategoryController showGoodsCategoryByTree is start...");
        ResponseMsg msg = goodsCategoryFeign.showGoodsCategoryByTree();
        logger.debug("GoodsCategoryController showGoodsCategoryByTree msg:"+msg);
        return msg;
    }

    @RequestMapping("getGoodsCategoryByCode")
    public ResponseMsg getGoodsCategoryByCode(String code) {
        logger.info("GoodsCategoryController getGoodsCategoryByCode code:"+code);
        ResponseMsg msg = goodsCategoryFeign.getGoodsCategoryByCode(code);
        logger.debug("GoodsCategoryController getGoodsCategoryByCode msg:"+msg);
        return msg;
    }

    @RequestMapping("getGoodsCategoryByName")
    public ResponseMsg getGoodsCategoryByName(String name) {
        logger.info("GoodsCategoryController getGoodsCategoryByName name:"+name);
        ResponseMsg msg = goodsCategoryFeign.getGoodsCategoryByName(name);
        logger.debug("GoodsCategoryController getGoodsCategoryByName msg:"+msg);
        return msg;
    }

    @RequestMapping("getGoodsCategoryByParentId")
    ResponseMsg getGoodsCategoryByParentId(Integer parentId){
        logger.info("GoodsCategoryController getGoodsCategoryByParentId parentId:"+parentId);
        ResponseMsg msg = goodsCategoryFeign.getGoodsCategoryByParentId(parentId);
        logger.debug("GoodsCategoryController getGoodsCategoryByParentId msg:"+msg);
        return msg;
    }
}
